﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "View/MyChartView.h"
#include <QtCharts>
//QT_CHARTS_USE_NAMESPACE
#include <QMainWindow>
#include <QThread>
#include <QTime>
#include <QStandardItemModel>
#include <QChart>
#include <QChartView>
#include "./View/servocontrol.h"
#include "./Manager/DispatchCore.h"
#include "./Manager/ParamConfig.h"
#include "./View/DeviceSettingsTab.h"
#include "./View/SearchTab.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void loadTableHeader();
    void loadPortFile();
    void loadChartView();
private slots:
    void slot_addLog(QString color,QString log);

    void on_btn_log_clicked();
    void slot_addCmdToTable(InOutCabCommand_Server cmd);

    void on_btn_cmddelete_clicked();

    void on_btn_cmdclear_clicked();

    void on_btn_servo_clicked();
    void slot_freshPortInfo(QVector<PortGoodsIndicator> portgoods,QList<InOutCabCommand_Server> cmdlist);
    void slot_chartViewClicked();
    void slot_freshChartView(DevArvStatisticsModel response);
    void on_btn_setup_clicked();

    void on_btn_search_clicked();

    void on_btn_opendoor_5_clicked();

signals:
    void sig_sendcmd();
    void sig_cmdDelete(int,QString);
    void sig_cmdClear();
    void sig_getDevArvStatistics();
private:
    Ui::MainWindow *ui;
    ServoControl *pServoControl;
    DispatchCore *pDispatchCore;
    DeviceSettingsTab *pDeviceSettingsTab;
    SearchTab *pSearchTab;
    QThread *pThread_dispatchCore;
    QStandardItemModel   *model;         // 配合TableView使用，在表格中显示数据
    QMap<CmdState,QString> mStateMap = {{CmdState_dead,"错误"},{CmdState_Ready,"就绪"},{CmdState_Blocked,"等待"},{CmdState_Running,"执行"},{CmdState_Suspended,"挂起"},{CmdState_Done,"完成"}};
    QList<QLabel *> mPortFile;
};
#endif // MAINWINDOW_H
